<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>打印机</title>
</head>
<body>
<div id="box" style="
	width:800px;
	height: 80px;
	line-height: 80px;
	font-size: 50px;
	font-weight: bold;
	margin:50px auto;
	border:5px solid skyblue;
	text-indent: 100px;
	letter-spacing: 4px;">
</div>	

<script>
	var wz = "天王盖地虎，宝塔镇河妖！";
	var direction = true;/*(direction)长度*/
	var len = 0;
	setInterval(function(){
		if(direction){
			len++;
			if(len >= wz.length){
				direction = false;
			}
		}else{
			len--;
			if(len <=0){
				direction = true;
			}
		}
		box.innerHTML = wz.substr(
			0,len);
	},1000);

</script>	
</body>
</html>